const fullscreen = {
  // 跨浏览器发动全屏
  lanchFullscreen: function (element) {
    if (element.requestFullscreen) {
      element.requestFullscreen()
    } else if (element.mozRequestFullScreen) {
      element.mozRequestFullScreen()
    } else if (element.msRequestFullscreen) {
      element.msRequestFullscreen()
    } else if (element.webkitRequestFullscreen) {
      element.webkitRequestFullscreen()
    }
  },
  // 跨浏览器退出全屏
  exitFullscreen: function () {
    if (document.exitFullscreen) {
      document.exitFullscreen()
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen()
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen()
    } else if (document.webkitCancelFullScreen) {
      document.webkitCancelFullScreen()
    }
  },
  // 跨浏览器返回当前 document 是否进入了可以请求全屏模式的状态
  fullscreenEnable: function () {
    let isFullscreen = document.fullscreenEnabled ||
      window.fullScreen ||
      document.webkitIsFullScreen ||
      document.msFullscreenEnabled
    //注意：要在用户授权全屏后才能准确获取当前的状态
    if (isFullscreen) {
      return true
    } else {
      return false
    }
  },
  // 跨浏览器返回正处于全屏的元素
  fullscreenElement: function () {
    let fullscreenEle = document.fullscreenElement ||
      document.mozFullScreenElement ||
      document.webkitFullscreenElement
    //注意：要在用户授权全屏后才能获取全屏的元素，否则 fullscreenEle为null
    return fullscreenEle
  }
}

export default fullscreen

/*

各浏览器fullscreenchange 事件处理

document.addEventListener('fullscreenchange', function(){ /*code })
document.addEventListener('webkitfullscreenchange', function(){ /*code })
document.addEventListener('mozfullscreenchange', function(){ /*code })
document.addEventListener('MSFullscreenChange', function(){ /*code })

 

各浏览器fullscreenerror 事件处理

document.addEventListener('fullscreenerror', function(){ /*code })
document.addEventListener('webkitfullscreenerror', function(){ /*code })
document.addEventListener('mozfullscreenerror', function(){ /*code })
document.addEventListener('MSFullscreenError', function(){ /*code })



跨浏览器全屏模式下样式代码

:-webkit-full-screen { /*code }
:-moz-full-screen { /*code }
:-ms-fullscreen { /*code }
:fullscreen { /*code }

 */

